<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>隔行变色</title>
	</head>
	<body>
		<ul>
			<li>1</li>
			<li>1</li>
			<li>1</li>
			<li>1</li>
			<li>1</li>
			<li>1</li>
			<li>1</li>
		</ul>
		<script type="text/javascript">
			//1.获取li对象
			//2.遍历数组：
			//偶数行：li对象的背景色设置为灰色
var lis=document.getElementsByTagName('li');
for(var i=0;i<lis.length;i++){
	if(i%2==0){
		lis[i].style.background='#ccc';
		
	}
}
</script>
	</body>
</html>
